$(function() {
	 
	loadStatics();
	 });
	 
	 function drawChart(year,monthArray,incomeArray,payoutArray){
	 var myChart = echarts.init(document.getElementById('main'));
	myChart.setOption({
	    title : {
	        text: year+'年各月份财政收支统计',
	        subtext: ''
	    },
	    tooltip : {
	        trigger: 'axis'
	    },
	    legend: {
	        data:['收入','支出']
	    },
	    toolbox: {
	        show : true,
	        feature : {
	            mark : {show: true},
	            dataView : {show: true, readOnly: false},
	            magicType : {show: true, type: ['line', 'bar']},
	            restore : {show: true},
	            saveAsImage : {show: true}
	        }
	    },
	    calculable : true,
	    xAxis : [
	        {
	            type : 'category',
	            boundaryGap : false,
	            data : monthArray
	        }
	    ],
	    yAxis : [
	        {
	            type : 'value',
	            axisLabel : {
	                formatter: '{value} 元'
	            }
	        }
	    ],
	    series : [
	        {
	            name:'收入',
	            type:'line',
	            data:incomeArray,
	            markPoint : {
	                data : [
	                    {type : 'max', name: '最高收入'},
	                    {type : 'min', name: '最低收入'}
	                ]
	            },
	            markLine : {
	                data : [
	                    {type : 'average', name: '平均收入'}
	                ]
	            }
	        },
	        {
	            name:'支出',
	            type:'line',
	            data:payoutArray,
	            markPoint : {
	                data : [
	                    {type : 'max', name: '最高支出'},
	                    {type : 'min', name: '最低支出'}
	                ]
	            },
	            markLine : {
	                data : [
	                    {type : 'average', name : '平均支出'}
	                ]
	            }
	        }
	    ]
	});
	 }
	 

	 
	 function loadStatics(){
	$.doAjaxCall("financeController.do?financeMonthSum",'',loadStaticsCallBack,true);
	}

	function loadStaticsCallBack(json){
		drawChart(json.year,json.monthArray, json.incomeArray, json.payoutArray);
	}